/////////////////////////////////////////////////////////////////////////

package sheep.view;

/////////////////////////////////////////////////////////////////////////

import java.awt.AlphaComposite;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Composite;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.IOException;

import java.util.Calendar;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.AbstractListModel;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;


import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.filechooser.FileFilter;
import javax.swing.table.TableCellRenderer;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import org.jdesktop.animation.timing.Animator;
import org.jdesktop.animation.timing.TimingTarget;
import org.jdesktop.animation.timing.interpolation.PropertySetter;
import org.jdesktop.fuse.InjectedResource;
import org.jdesktop.fuse.ResourceInjector;
import org.jdesktop.swingx.JXPanel;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.StackLayout;
import org.jdesktop.swingx.VerticalLayout;
import org.jdesktop.swingx.util.SwingWorker;

import sheep.controller.Workspace;
import sheep.model.Project;
import sheep.model.Task;
import sheep.model.Worker;
import sheep.model.graph.CyclicGraphException;
import sheep.model.graph.Graph;
import sheep.model.graph.Graph.Direction;
import sheep.utils.fileio.Bundles;
import sheep.view.Component.ActionButton;
import sheep.view.Component.HyperlinkHandler;
import sheep.view.Component.RoundedPanel;
import sheep.view.Component.SheepScrollbarUI;
import sheep.view.Component.StyledDropDown;
import sheep.view.Component.TaskManualCreateTableModel;
import sheep.view.Component.UserCellRenderer;
import sheep.view.ProjectManualEditPanel.TaskCreateMode;
import sheep.view.UserChooserTopPanel.PanelMode;
import sheep.view.effects.ComponentEffect;
import sheep.view.effects.CompositeEffect;
import sheep.view.effects.EffectsManager;
import sheep.view.effects.Move;
import sheep.view.effects.Rotate;
import sheep.view.graphics2d.Reflection;

/////////////////////////////////////////////////////////////////////////
import sheep.view.transitions.ScreenTransition;
import sheep.view.utils.swingx.DropShadowPanel;

// Panneau de projet principal
class ProjectNewPanel extends JPanel {
  
  /////////////////////////////////////////////////////////////////////////

    // Zone de bouttons
    private JPanel buttonPanel;
    // Zoom de raccourccis
    private JPanel leftPanel, rightPanel, thirdPanel, fourthPanel, fifthPanel;
    // Position du reflet
    private float shadowOffsetX;
    private float shadowOffsetY;
    // Flag de survol
    private boolean mouseEnter = false;

    Workspace workSpace;
    
      // Variables declaration - do not modify GAUCHE
  private javax.swing.JPanel beginDatePanel;
  private org.jdesktop.swingx.JXDatePicker beginDatePicker;
  private javax.swing.JLabel beginLabel;
  private javax.swing.JPanel beginPanel;
  private javax.swing.JPanel calendrierPanel;
  private javax.swing.JComboBox categorieComboBox;
  private javax.swing.JLabel categorieLabel;
  private javax.swing.JLabel commentLabel;
  private javax.swing.JPanel commentPanel;
  private javax.swing.JScrollPane commentScrollPane;
  private javax.swing.JTextArea commentTextArea;
  private javax.swing.JPanel endDatePanel;
  private org.jdesktop.swingx.JXDatePicker endDatePicker;
  private javax.swing.JLabel endLabel;
  private javax.swing.JPanel endPanel;
  private javax.swing.JPanel mainLeftPanel;
  private javax.swing.JLabel nameLabel;
  private javax.swing.JPanel namePanel;
  private javax.swing.JTextField nameTextField;
  private javax.swing.JLabel titleLabel;
  private javax.swing.JPanel titlePanel;
  // End of variables declaration
  
  // Variables declaration - do not modify DROITE
  private javax.swing.JLabel ImageLabel;
  private javax.swing.JPanel imageLeftPanel;
  private javax.swing.JButton imageModifButton;
  private javax.swing.JPanel imagePanel;
  private org.jdesktop.swingx.JXImagePanel jXImagePanel;
  private javax.swing.JPanel mainRightPanel;
  private javax.swing.JButton managerAddButton1;
  private javax.swing.JButton managerDeleteButton1;
  private javax.swing.JLabel managerLabel;
  private javax.swing.JPanel managerLeftPanel;
  private javax.swing.JScrollPane managerListScrollPane;
  private javax.swing.JPanel managerPanel;
  private javax.swing.JLabel titleRightLabel;
  private javax.swing.JPanel titleRightPanel;
  private javax.swing.JButton userAddButton;
  private javax.swing.JButton userDeleteButton;
  private javax.swing.JLabel userLabel;
  private javax.swing.JPanel userLeftPanel;
  private javax.swing.JList userList;
  private javax.swing.JList userList1;
  private javax.swing.JScrollPane userListScrollPane;
  private javax.swing.JPanel userPanel;
  // End of variables declaration  
  
  
    // Variables declaration - do not modify   3EME PANEL
  private javax.swing.JLabel folderLabel;
  private javax.swing.JButton folderModifButton;
  private javax.swing.JPanel folderPanel;
  private javax.swing.JTextField folderTextField;
  private javax.swing.JPanel mainThirdPanel;
  private javax.swing.JButton taskGantButton;
  private javax.swing.JButton taskGraphButton;
  private javax.swing.JButton taskInfosButton;
  private javax.swing.JLabel taskLabel;
  private javax.swing.JScrollPane taskScrollPane;
  private javax.swing.JTree taskTree;
  private javax.swing.JPanel taskTreeLeftPanel;
  private javax.swing.JPanel taskTreePanel;
  private javax.swing.JLabel titleThirdLabel;
  private javax.swing.JPanel titleThirdPanel;
  // End of variables declaration
  
  
    // Variables declaration - do not modify    4EME PAGE
  private javax.swing.JButton UserTaskAddButton;
  private javax.swing.JLabel UserTaskLabel;
  private javax.swing.JPanel UserTaskLeftPanel;
  private javax.swing.JList UserTaskList;
  private javax.swing.JButton UserTaskOpenButton;
  private javax.swing.JPanel UserTaskPanel;
  private javax.swing.JButton UserTaskRemButton;
  private javax.swing.JScrollPane UserTaskScrollPane;
  private javax.swing.JLabel beginDateTaskLabel;
  private javax.swing.JPanel beginDateTaskPanel;
  private org.jdesktop.swingx.JXDatePicker beginDateTaskXDatePicker;
  private javax.swing.JButton documentAddButton;
  private javax.swing.JLabel documentLabel;
  private javax.swing.JPanel documentLeftPanel;
  private javax.swing.JList documentList;
  private javax.swing.JButton documentOpenButton;
  private javax.swing.JPanel documentPanel;
  private javax.swing.JButton documentRemButton;
  private javax.swing.JScrollPane documentScrollPane;
  private javax.swing.JLabel durationTaskLabel;
  private javax.swing.JButton durationTaskModifButton;
  private javax.swing.JPanel durationTaskPanel;
  private javax.swing.JTextField durationTaskTextField;
  private javax.swing.JLabel endDateTaskLabel;
  private javax.swing.JPanel endDateTaskPanel;
  private org.jdesktop.swingx.JXDatePicker endDateTaskXDatePicker;
  private javax.swing.JPanel mainFourthPanel;
  private javax.swing.JLabel titleFourthLabel;
  private javax.swing.JPanel titleFourthPanel;
  // End of variables declaration
  
    // Variables declaration - do not modify    5EME PAGE
  private javax.swing.JButton dependanceLeftAddButton;
  private javax.swing.JButton dependanceLeftEditButton;
  private javax.swing.JPanel dependanceLeftPanel;
  private javax.swing.JButton dependanceLeftRemButton;
  private javax.swing.JPanel dependancePanel;
  private javax.swing.JScrollPane dependanceScrollPane;
  private javax.swing.JPanel dependanceSouthCenterPanel;
  private javax.swing.JButton dependanceSouthDefCurrentButton;
  private javax.swing.JButton dependanceSouthGantButton;
  private javax.swing.JButton dependanceSouthGrapheButton;
  private javax.swing.JPanel dependanceSouthLeftPanel;
  private javax.swing.JPanel dependanceSouthPanel;
  private javax.swing.JPanel dependanceSouthRightPanel;
  private javax.swing.JButton dependanceSouthSupertaskButton;
  private javax.swing.JButton dependanceSouthUsersButton;
  private JXTable dependanceTable;
  private javax.swing.JLabel documentLabel1;
  private javax.swing.JPanel mainFifthPanel;
  private javax.swing.JLabel titleFifthLabel;
  private javax.swing.JPanel titleFifthPanel;  
  
  
  JButton nextButton, precButton;
  
  JPanel innerPanel;
  private static final int TRANSITION_TIME_IN_MILLIS = 1000;
  private TaskManualCreateTableModel usersTableModel;
  
  private enum ScreenType { FIRST,SECOND,THIRD, FOURTH }
  // Valeur des ecrans courant et precedent
  private ScreenType currentScreen;  
  
  // Gestionnaire de transitions utilisee    
  private ScreenTransition screenTransition; 
  
  Animator leftFirstAnimator,rightFirstAnimator;
  Animator leftSecondAnimator,rightSecondAnimator;
  Animator leftThirdAnimator,rightThirdAnimator;
 Animator leftFourthAnimator,rightFourthAnimator;
 
  private UserChooserTopPanel userChooserTopPanel; 
  private ProjectManualEditPanel manualEditPanel;

  RoundedPanel r;
    ////////////////////////////////////////////////////////////////////////////
    // THEME SPECIFIC FIELDS
    ////////////////////////////////////////////////////////////////////////////
    
    @InjectedResource
    private float shadowOpacity;
    @InjectedResource
    private Color shadowColor;
    @InjectedResource
    private int shadowDistance;
    @InjectedResource
    private int shadowDirection;
    @InjectedResource
    private Font categoryFont;
    @InjectedResource
    private Font categorySmallFont;
    @InjectedResource
    private float categorySmallOpacity;
    @InjectedResource
    private Color categoryColor;
    @InjectedResource
    private Color categoryHighlightColor;


    
    private void configureAnimations() {
        leftFirstAnimator = new Animator(300);
        leftFirstAnimator.setAcceleration(0.3f);
        leftFirstAnimator.setDeceleration(0.2f);
        leftFirstAnimator.addTarget(new PropertySetter(
                fifthPanel, "location", new Point(1560,0 ))); 
        leftFirstAnimator.addTarget(new PropertySetter(
                fourthPanel, "location", new Point(1040,0 )));        
        leftFirstAnimator.addTarget(new PropertySetter(
                thirdPanel, "location", new Point(520,0 )));      
        leftFirstAnimator.addTarget(new PropertySetter(
                leftPanel, "location", new Point(-520,0) ));
        leftFirstAnimator.addTarget(new PropertySetter(
                rightPanel, "location", new Point(0,0 )));
    

        leftSecondAnimator = new Animator(300);
        leftSecondAnimator.setAcceleration(0.3f);
        leftSecondAnimator.setDeceleration(0.2f);
        leftSecondAnimator.addTarget(new PropertySetter(
                fifthPanel, "location", new Point(1040,0 ))); 
        leftSecondAnimator.addTarget(new PropertySetter(
                fourthPanel, "location", new Point(520,0 )));          
        leftSecondAnimator.addTarget(new PropertySetter(
                thirdPanel, "location", new Point(0,0 )));      
        leftSecondAnimator.addTarget(new PropertySetter(
                leftPanel, "location", new Point(-1040,0) ));
        leftSecondAnimator.addTarget(new PropertySetter(
                rightPanel, "location", new Point(-520,0 )));
 
        
        leftThirdAnimator = new Animator(600);
        leftThirdAnimator.setAcceleration(0.3f);
        leftThirdAnimator.setDeceleration(0.2f);
        leftThirdAnimator.addTarget(new PropertySetter(
                fifthPanel, "location", new Point(0,0 ))); 
        leftThirdAnimator.addTarget(new PropertySetter(
                fourthPanel, "location", new Point(-520,0 )));          
        leftThirdAnimator.addTarget(new PropertySetter(
                thirdPanel, "location", new Point(-1040,0 )));      
        leftThirdAnimator.addTarget(new PropertySetter(
                leftPanel, "location", new Point(-1560,0) ));
        leftThirdAnimator.addTarget(new PropertySetter(
                rightPanel, "location", new Point(-2080,0 ))); 

        
        rightFirstAnimator = new Animator(300);
        rightFirstAnimator.setAcceleration(0.3f);
        rightFirstAnimator.setDeceleration(0.2f);      
        rightFirstAnimator.addTarget(new PropertySetter(
                leftPanel, "location", new Point(0,0 )));
        rightFirstAnimator.addTarget(new PropertySetter(
                rightPanel, "location",new Point(520,0 )));
        rightFirstAnimator.addTarget(new PropertySetter(
                thirdPanel, "location", new Point(1040,0 ))); 
        rightFirstAnimator.addTarget(new PropertySetter(
                fourthPanel, "location", new Point(1560,0 ))); 
        rightFirstAnimator.addTarget(new PropertySetter(
                fifthPanel, "location", new Point(2080,0 ))); 
        
        rightSecondAnimator = new Animator(300);
        rightSecondAnimator.setAcceleration(0.3f);
        rightSecondAnimator.setDeceleration(0.2f);
        rightSecondAnimator.addTarget(new PropertySetter(
                leftPanel, "location", new Point(-520,0 )));
        rightSecondAnimator.addTarget(new PropertySetter(
                rightPanel, "location",new Point(0,0 )));
        rightSecondAnimator.addTarget(new PropertySetter(
                thirdPanel, "location", new Point(520,0 )));        
        rightSecondAnimator.addTarget(new PropertySetter(
                fourthPanel, "location", new Point(1040,0 )));  
        rightSecondAnimator.addTarget(new PropertySetter(
                fifthPanel, "location", new Point(1560,0 ))); 
        
        rightThirdAnimator = new Animator(600);
        rightThirdAnimator.setAcceleration(0.3f);
        rightThirdAnimator.setDeceleration(0.2f);
        rightThirdAnimator.addTarget(new PropertySetter(
                leftPanel, "location", new Point(-1040,0 )));
        rightThirdAnimator.addTarget(new PropertySetter(
                rightPanel, "location",new Point(-520,0 )));
        rightThirdAnimator.addTarget(new PropertySetter(
                thirdPanel, "location", new Point(0,0 )));        
        rightThirdAnimator.addTarget(new PropertySetter(
                fourthPanel, "location", new Point(520,0 )));
        rightThirdAnimator.addTarget(new PropertySetter(
                fifthPanel, "location", new Point(1040,0 ))); 
              
            

    }    
    private void refreshInner(){
      if (workSpace.getCurrentTask() != null){
          titleFourthLabel.setText("DETAILS : "+workSpace.getCurrentTask().getName());
          titleFifthLabel.setText("Sous taches : "+workSpace.getCurrentTask().getName());
          beginDateTaskXDatePicker.setDate(workSpace.getCurrentTask().getActualBeginTime().getTime());
          endDateTaskXDatePicker.setDate(workSpace.getCurrentTask().getActualEndTime().getTime());
      }
      if (workSpace.getCurrentProject() != null){
        nameTextField.setText(workSpace.getCurrentProject().getName());
        beginDatePicker.setDate(workSpace.getCurrentProject().getActualBeginTime().getTime());
        endDatePicker.setDate(workSpace.getCurrentProject().getEarliestEndTime().getTime());      
        commentTextArea.setText(workSpace.getCurrentProject().getComment());
        try{  

   //           ((Project)workSpace.getCurrentProject()).getGraph().writeJPEGImage(
  //                    "C:\\Temp\\"+((Project)workSpace.getCurrentProject()).getName() +".jpg", true);
              if (((Project)workSpace.getCurrentProject()).getPicturePath()!=null)
              jXImagePanel.setImage(ResizingImage.resize(
                      80, 80,((Project)workSpace.getCurrentProject()).getPicturePath()));
   //           ((Project)workSpace.getCurrentProject()).setPictures(
  //                    ResizingImage.resize(580, 580,"C:\\Temp\\"+((Project)workSpace.getCurrentProject()).getName() +".jpg"));
  //            ((Project)workSpace.getCurrentProject()).setPicturePath(
  //                    "C:\\Temp\\"+((Project)workSpace.getCurrentProject()).getName() +".jpg");
          
        }catch(Exception e){}
        
        if (workSpace.getCurrentProject() instanceof Project)
        if(((Project)workSpace.getCurrentProject()).getProjectPath()!=null)
          folderTextField.setText(((Project)workSpace.getCurrentProject()).getProjectPath());
        else
          folderTextField.setText("");
        
        taskScrollPane.setViewportView(taskTree);
        taskTree.repaint();
        taskScrollPane.repaint();
      }
      
      userList.repaint();
      userList1.repaint();
      UserTaskList.repaint();
      
      if (workSpace.getCurrentTask()!=null){
            LinkedList<Task> list= workSpace.getCurrentTask().getTaskList(false, false);
            list.remove(workSpace.getCurrentTask());
            usersTableModel.setData(list);
            dependanceTable.setModel(usersTableModel);
            dependanceTable.repaint();
      }
      
      if (dependanceTable.getSelectedRow()< usersTableModel.getList().size()){
         Task t  = usersTableModel.getList().get(dependanceTable.getSelectedRow());
         workSpace.setSelectedTask(t);
        }
      
      /*
     if (workSpace.getCurrentTask()!=null){
        dependanceTable.setModel(new javax.swing.table.DefaultTableModel(
        workSpace.getCurrentTask().getTaskTab(false,false),
        new String [] {
          "Nom", "Date de début", "Date de fin", "Taches nécessaires"
        }
      ));        
      }else{
      dependanceTable.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null}
        },
        new String [] {
          "Nom", "Date de début", "Date de fin", "Taches nécessaires"
        }
      ));
      }  
      */
    }
    
    
    
    public void refresh(){
      if (workSpace.getCurrentTask() != null){
          titleFourthLabel.setText("DETAILS : "+workSpace.getCurrentTask().getName());
          titleFifthLabel.setText("Sous taches : "+workSpace.getCurrentTask().getName());
          beginDateTaskXDatePicker.setDate(workSpace.getCurrentTask().getActualBeginTime().getTime());
          endDateTaskXDatePicker.setDate(workSpace.getCurrentTask().getActualEndTime().getTime());
      }
      if (workSpace.getCurrentProject() != null){
        nameTextField.setText(workSpace.getCurrentProject().getName());
        beginDatePicker.setDate(workSpace.getCurrentProject().getActualBeginTime().getTime());
        endDatePicker.setDate(workSpace.getCurrentProject().getEarliestEndTime().getTime());      
        commentTextArea.setText(workSpace.getCurrentProject().getComment());
        try{  
          
       //       ((Project)workSpace.getCurrentProject()).getGraph().writeJPEGImage(
       //               "C:\\Temp\\"+((Project)workSpace.getCurrentProject()).getName() +".jpg", true);
              if (((Project)workSpace.getCurrentProject()).getPicturePath()!=null)
              jXImagePanel.setImage(ResizingImage.resize(
                      80, 80,((Project)workSpace.getCurrentProject()).getPicturePath()));
    //          ((Project)workSpace.getCurrentProject()).setPictures(
    //                  ResizingImage.resize(580, 580,"C:\\Temp\\"+((Project)workSpace.getCurrentProject()).getName() +".jpg"));
    //          ((Project)workSpace.getCurrentProject()).setPicturePath(
    //                  "C:\\Temp\\"+((Project)workSpace.getCurrentProject()).getName() +".jpg");
          
        }catch(Exception e){}
        
        if (workSpace.getCurrentProject() instanceof Project)
        if(((Project)workSpace.getCurrentProject()).getProjectPath()!=null)
          folderTextField.setText(((Project)workSpace.getCurrentProject()).getProjectPath());
        else
          folderTextField.setText("");
        
        taskTree.setModel(new JTree (getTaskTree(workSpace.getCurrentProject())).getModel());
        taskScrollPane.setViewportView(taskTree);
        taskTree.repaint();
        taskScrollPane.repaint();
      }
      
      userList.repaint();
      userList1.repaint();
      UserTaskList.repaint();
      
      if (workSpace.getCurrentTask()!=null){
            LinkedList<Task> list= workSpace.getCurrentTask().getTaskList(false, false);
            list.remove(workSpace.getCurrentTask());
            usersTableModel.setData(list);
            dependanceTable.setModel(usersTableModel);
            dependanceTable.repaint();
      }
              
      if (dependanceTable.getSelectedRow()>=0){
         Task t  = usersTableModel.getList().get(dependanceTable.getSelectedRow());
         workSpace.setSelectedTask(t);
        }      
      /*
      if (workSpace.getCurrentTask()!=null){
        dependanceTable.setModel(new javax.swing.table.DefaultTableModel(
        workSpace.getCurrentTask().getTaskTab(false,false),
        new String [] {
          "Nom", "Date de début", "Date de fin", "Taches nécessaires"
        }
      ));        
      }else{
      dependanceTable.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null},
          {null, null, null, null}
        },
        new String [] {
          "Nom", "Date de début", "Date de fin", "Taches nécessaires"
        }
      ));
      }
      */
      
    }
    
    public DefaultMutableTreeNode getTaskTree(Task newTask){
      DefaultMutableTreeNode root = new DefaultMutableTreeNode(newTask.getName());
    for(Task t : newTask.getTaskList(false, false)) {
      if (!t.getName().equals(newTask.getName())&&
           !t.getName().equals("start")&&
           !t.getName().equals("end")){
      root.add(getTaskTree(t));
      System.out.println("arbre : " + t.getName());
      }
    }
    return root;
    }
    
    ProjectNewPanel(Workspace workSpace) {
        // Charger les attributs pecedents depuis le fichier de conf
        ResourceInjector.get().inject(this);
        this.workSpace =workSpace;
        
        // On s'oocupe de l'arriere plan
        setOpaque(false);
        // Layout
        setLayout(new BorderLayout());
        // Calcul de la position de l'ombre
        computeShadow();
        // Ajout des composants
        JPanel centerPanel = new JPanel(new BorderLayout());
        centerPanel.setOpaque(false);
        centerPanel.add(BorderLayout.CENTER, buildProjectInfoPanel());
        centerPanel.add(BorderLayout.SOUTH, buildProjectVisualisationPanel());
        setTasks();
        
        userChooserTopPanel = new UserChooserTopPanel(this.workSpace);   
        JXPanel centerSatckPanel = new JXPanel(new StackLayout());
        centerSatckPanel.setOpaque(false);
        centerSatckPanel. add(centerPanel, StackLayout.TOP);
        userChooserTopPanel.setVisible2(false);
        centerSatckPanel.add(userChooserTopPanel,StackLayout.TOP );    
        add(centerSatckPanel, BorderLayout.CENTER);

    
        
        	
	ComponentEffect moveEffect = new Move(null, null);
	ComponentEffect rotateEffect = new Rotate(null, null, 360, 15, 10);
	CompositeEffect compositeEffect = new CompositeEffect(moveEffect);
	compositeEffect.addEffect(rotateEffect);
	EffectsManager.setEffect(innerPanel, compositeEffect, 
		EffectsManager.TransitionType.CHANGING);
         
        
        configureAnimations();
        
        //screenTransition = new ScreenTransition(this, 
        //new ContentTransitionTarget());
        currentScreen = ScreenType.FIRST;
    }

    /////////////////////////////////////////////////////////////////////////

    // création de la zone operation en haut
        private JPanel buildProjectInfoPanel() {
        // Nouveau panel
        JPanel taskPanel = new JPanel(new BorderLayout());
        taskPanel.setOpaque(false);
        // Ajout d'un titre floutés
        taskPanel.add(BorderLayout.NORTH, new BackgroundMenuTitle(
                Bundles.getMessage(getClass(), "TXT_NewProjet")));
        
        //GridLayout gridLayout =new GridLayout(1,2);
        //gridLayout.setHgap(20);
        innerPanel = new JPanel(null);
        innerPanel.setOpaque(false);
        // Sous panel
        leftPanel = new DropShadowPanel();
        leftPanel.setOpaque(false);                
        leftPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 10, 1, 10));
        leftPanel.setOpaque(false);
        leftPanel.setLayout(new java.awt.BorderLayout());
        leftPanel.setBounds(0, 0, 480, 500);
        leftPanel.setPreferredSize(new java.awt.Dimension(480, 500));
        
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
        
        ////////////////////////
        // 1ERE PAGE
        
        mainLeftPanel = new javax.swing.JPanel();
        titlePanel = new DropShadowPanel();
        titleLabel = new javax.swing.JLabel();
        namePanel = new javax.swing.JPanel();
        nameLabel = new javax.swing.JLabel();
        nameTextField = new javax.swing.JTextField();
        calendrierPanel = new javax.swing.JPanel();
        categorieLabel = new javax.swing.JLabel();
        categorieComboBox = new javax.swing.JComboBox();
        beginPanel = new javax.swing.JPanel();
        beginLabel = new javax.swing.JLabel();
        beginDatePanel = new javax.swing.JPanel();
        beginDatePicker = new org.jdesktop.swingx.JXDatePicker();
        endPanel = new javax.swing.JPanel();
        endDatePanel = new javax.swing.JPanel();
        endDatePicker = new org.jdesktop.swingx.JXDatePicker();
        endLabel = new javax.swing.JLabel();
        commentPanel = new javax.swing.JPanel();
        commentLabel = new javax.swing.JLabel();
        commentScrollPane = new javax.swing.JScrollPane();
        commentTextArea = new javax.swing.JTextArea();


        mainLeftPanel.setOpaque(false);
        VerticalLayout verticalLayout1 = new VerticalLayout();
        verticalLayout1.setGap(15);
        mainLeftPanel.setLayout(verticalLayout1);
        
        titlePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        titlePanel.setOpaque(false);
        titlePanel.setPreferredSize(new java.awt.Dimension(258, 30));
        titlePanel.setLayout(new java.awt.BorderLayout());

        titleLabel.setFont(new java.awt.Font("Times New Roman", 1, 24));
        titleLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        titleLabel.setText("GENERAL");
        titleLabel.setForeground(new java.awt.Color(255, 255, 255));
        titlePanel.add(titleLabel, java.awt.BorderLayout.CENTER);

        mainLeftPanel.add(titlePanel);

        namePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        namePanel.setOpaque(false);
        namePanel.setLayout(new java.awt.BorderLayout());

        nameLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        nameLabel.setText("Titre:");
        nameLabel.setForeground(new java.awt.Color(255, 255, 255));
        nameLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        namePanel.add(nameLabel, java.awt.BorderLayout.WEST);

        nameTextField.setFont(new java.awt.Font("Times New Roman", 1, 14));
        nameTextField.setBorder(BorderFactory.createEmptyBorder());
        nameTextField.setText("");
        nameTextField.setOpaque(false);
        nameTextField.setPreferredSize(new java.awt.Dimension(296, 20));
        nameTextField.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            workSpace.getCurrentProject().setName(nameTextField.getText());
            refresh();
            
          }
        });
        namePanel.add(new RoundedPanel(nameTextField,0,0,0,0), java.awt.BorderLayout.CENTER);

        mainLeftPanel.add(new RoundedPanel(namePanel));

        calendrierPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        calendrierPanel.setOpaque(false);
        calendrierPanel.setLayout(new java.awt.BorderLayout());

        categorieLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        categorieLabel.setText("Categorie");
        categorieLabel.setForeground(new java.awt.Color(255, 255, 255));
        categorieLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        calendrierPanel.add(categorieLabel, java.awt.BorderLayout.WEST);

        categorieComboBox.setFont(new java.awt.Font("Times New Roman", 1, 14));
        categorieComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        categorieComboBox.setOpaque(false);
        categorieComboBox.setPreferredSize(new java.awt.Dimension(296, 20));
        StyledDropDown styledDropDown =new StyledDropDown(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" });
        calendrierPanel.add(new RoundedPanel(styledDropDown,0,0,0,0), java.awt.BorderLayout.CENTER);

        //mainLeftPanel.add(new RoundedPanel(calendrierPanel));

        GridLayout gridLayout2 =new GridLayout(2,1);
        gridLayout2.setVgap(10);
        JPanel dateTempPanel = new JPanel(gridLayout2);
        dateTempPanel.setPreferredSize(new java.awt.Dimension(327, 80));
        dateTempPanel.setOpaque(false);
        
        beginPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        beginPanel.setOpaque(false);
        beginPanel.setPreferredSize(new java.awt.Dimension(327, 30));
        beginPanel.setLayout(new java.awt.BorderLayout());

        beginLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        beginLabel.setText("Date de début");
        beginLabel.setForeground(new java.awt.Color(255, 255, 255));
        beginLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        beginPanel.add(beginLabel, java.awt.BorderLayout.WEST);

        beginDatePanel.setOpaque(false);
        beginDatePanel.setPreferredSize(new java.awt.Dimension(306, 20));
        beginDatePanel.setLayout(new java.awt.BorderLayout());

        beginDatePicker.setFont(new java.awt.Font("Times New Roman", 1, 14));
        beginDatePicker.setPreferredSize(new java.awt.Dimension(134, 22));
        
        beginDatePicker.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Calendar calTemp = Calendar.getInstance();
            calTemp.setTime(beginDatePicker.getDate());
            workSpace.getCurrentProject().setActualBeginTime(calTemp, true);//.getActualBeginTime().setTime(beginDatePicker.getDate());
            workSpace.getCurrentProject().setEarliestBeginTime(calTemp, true);
            workSpace.getCurrentProject().setLatestBeginTime(calTemp, true);
            workSpace.getCurrentProject().getGraph().getStartTask().setActualBeginTime(calTemp, true);
            workSpace.getCurrentProject().getGraph().criticalPath(true);
            if (workSpace.getCurrentTask()!=null)
              beginDateTaskXDatePicker.setDate(workSpace.getCurrentTask().getActualBeginTime().getTime());
              refresh();
          }
        });
        beginDatePanel.add(beginDatePicker, java.awt.BorderLayout.CENTER);

        beginPanel.add(beginDatePanel, java.awt.BorderLayout.CENTER);

        dateTempPanel.add(beginPanel);

        endPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        endPanel.setOpaque(false);
        endPanel.setPreferredSize(new java.awt.Dimension(258, 30));
        endPanel.setLayout(new java.awt.BorderLayout());

        endDatePanel.setOpaque(false);
        endDatePanel.setPreferredSize(new java.awt.Dimension(306, 20));
        endDatePanel.setLayout(new java.awt.BorderLayout());

        endDatePicker.setFont(new java.awt.Font("Times New Roman", 1, 14));
        endDatePicker.setPreferredSize(new java.awt.Dimension(134, 22));
        endDatePicker.setOpaque(false);
        endDatePicker.setEnabled(false);
        
        endDatePicker.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Calendar calTemp = Calendar.getInstance();
            calTemp.setTime(endDatePicker.getDate());
            workSpace.getCurrentProject().setActualEndTime(calTemp, true);//.getActualEndTime().setTime(endDatePicker.getDate());
            if (workSpace.getCurrentTask()!=null)
              endDateTaskXDatePicker.setDate(workSpace.getCurrentTask().getActualEndTime().getTime());
            refresh();
          }
        });        
        endDatePanel.add(endDatePicker, java.awt.BorderLayout.CENTER);

        endPanel.add(endDatePanel, java.awt.BorderLayout.CENTER);

        endLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        endLabel.setText("Date de fin");
        endLabel.setForeground(new java.awt.Color(255, 255, 255));
        endLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        endPanel.add(endLabel, java.awt.BorderLayout.WEST);

        dateTempPanel.add(endPanel);
        mainLeftPanel.add(new RoundedPanel(dateTempPanel));

        
        commentPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        commentPanel.setOpaque(false);
        commentPanel.setPreferredSize(new java.awt.Dimension(327, 140));
        commentPanel.setLayout(new java.awt.BorderLayout());

        commentLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        commentLabel.setText("Commentaires");
        commentLabel.setForeground(new java.awt.Color(255, 255, 255));
        commentLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        commentPanel.add(commentLabel, java.awt.BorderLayout.WEST);

        commentScrollPane.setBorder(null);
        commentScrollPane.setOpaque(false);
        commentScrollPane.getVerticalScrollBar().setUI(new SheepScrollbarUI());
        commentTextArea.setColumns(20);
        commentTextArea.setRows(5);
        commentTextArea.setOpaque(false);
        commentTextArea.setPreferredSize(new java.awt.Dimension(164, 80));
        commentTextArea.addKeyListener(new KeyListener(){
          @Override
          public void keyTyped(KeyEvent e) {
            workSpace.getCurrentProject().setComment(commentTextArea.getText());
          }
          @Override
          public void keyPressed(KeyEvent e) {}
          @Override
          public void keyReleased(KeyEvent e) {}
        });
        commentScrollPane.setViewportView(commentTextArea);

        commentPanel.add(new RoundedPanel(commentScrollPane,5,5,5,5), java.awt.BorderLayout.CENTER);

        mainLeftPanel.add(new RoundedPanel(commentPanel));

        leftPanel.add(mainLeftPanel, java.awt.BorderLayout.CENTER);       
        
        //Ajout au panel principal
        innerPanel.add(leftPanel);
         
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
        
        //////////////////////////
        // 2ND PAGE
        
        rightPanel = new DropShadowPanel();
        rightPanel.setOpaque(false);
        rightPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 10, 1, 10));
        rightPanel.setLayout(new java.awt.BorderLayout());
        rightPanel.setBounds(520, 0, 480, 500);
        rightPanel.setPreferredSize(new java.awt.Dimension(480, 500));
        
        mainRightPanel = new javax.swing.JPanel();
        titleRightPanel = new DropShadowPanel();
        titleRightLabel = new javax.swing.JLabel();
        managerPanel = new javax.swing.JPanel();
        managerListScrollPane = new javax.swing.JScrollPane();
        userList1 = new javax.swing.JList();
        managerLeftPanel = new javax.swing.JPanel();
        managerLabel = new javax.swing.JLabel();
        managerAddButton1 = new ActionButton("+",new Dimension (35,25));
        managerDeleteButton1 = new ActionButton("-",new Dimension (35,25));
        userPanel = new javax.swing.JPanel();
        userListScrollPane = new javax.swing.JScrollPane();
        userList = new javax.swing.JList();
        userLeftPanel = new javax.swing.JPanel();
        userLabel = new javax.swing.JLabel();
        userAddButton = new ActionButton("+",new Dimension (35,25));
        userDeleteButton = new ActionButton("-",new Dimension (35,25));
        imagePanel = new javax.swing.JPanel();
        imageLeftPanel = new javax.swing.JPanel();
        ImageLabel = new javax.swing.JLabel();
        imageModifButton = new ActionButton();
        jXImagePanel = new org.jdesktop.swingx.JXImagePanel();

        mainRightPanel.setOpaque(false);
        VerticalLayout verticalLayout2 = new VerticalLayout();
        verticalLayout2.setGap(15);
        mainRightPanel.setLayout(verticalLayout2);

        titleRightPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        titleRightPanel.setOpaque(false);
        titleRightPanel.setPreferredSize(new java.awt.Dimension(258, 30));
        titleRightPanel.setLayout(new java.awt.BorderLayout());

        titleRightLabel.setFont(new java.awt.Font("Times New Roman", 1, 24));
        titleRightLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        titleRightLabel.setText("INFORMATIONS");
        titleRightLabel.setForeground(new java.awt.Color(255, 255, 255));
        titleRightPanel.add(titleRightLabel, java.awt.BorderLayout.CENTER);

        mainRightPanel.add(titleRightPanel);

        userPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        userPanel.setOpaque(false);
        userPanel.setPreferredSize(new java.awt.Dimension(117, 100));
        userPanel.setLayout(new java.awt.BorderLayout());

        userListScrollPane.setBorder(null);
        userListScrollPane.setOpaque(false);
        userListScrollPane.getVerticalScrollBar().setUI(new SheepScrollbarUI());
        UserListModel ParticipantUserListModel =new UserListModel(workSpace);
        userList.setModel(ParticipantUserListModel);
        userList.setOpaque(false);
        userList.setPreferredSize(new java.awt.Dimension(33, 100));
        userList.setName("project");
        userListScrollPane.setViewportView(userList);

        userPanel.add(new RoundedPanel(userListScrollPane,5,5,5,5), java.awt.BorderLayout.CENTER);

        userLeftPanel.setPreferredSize(new java.awt.Dimension(100, 31));
        userLeftPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 10));
        userLeftPanel.setOpaque(false);
        
        userLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        userLabel.setForeground(new java.awt.Color(255, 255, 255));
        userLabel.setText("Participants :");
        userLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        userLeftPanel.add(userLabel);

        userAddButton.setText("+");
        userAddButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            userChooserTopPanel.setPanelMode(PanelMode.PROJECT);
            Component[] comp ={userList ,
              workSpace.getCurrentProject() == workSpace.getCurrentTask() ?  UserTaskList: null}; 
            userChooserTopPanel.setRepaintComponent(comp);
            userChooserTopPanel.repaintTable();
            userChooserTopPanel.setVisible(true);
            userList.repaint();
            UserTaskList.repaint();
          }
        });


        userLeftPanel.add(userAddButton);

        userDeleteButton.setText("-");
        userDeleteButton.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
             if(userList.getSelectedValues().length!=0 && 
                     userList.getSelectedIndex() < userList.getModel().getSize()){           
               UserListModel  model = (UserListModel)userList.getModel();
               workSpace.getCurrentProject().getWorkersList().remove( 
                       model.getWorker(userList.getSelectedIndex()));
               //model.deleteWorker(model.getWorker(userList.getSelectedIndex()));
               userChooserTopPanel.setPanelMode(PanelMode.PROJECT);
               Component[] comp ={userList ,
                  workSpace.getCurrentProject() == workSpace.getCurrentTask() ?  UserTaskList: null}; 
               userChooserTopPanel.setRepaintComponent(comp);
               userChooserTopPanel.repaintTable();
               userList.repaint();
               UserTaskList.repaint();
             }
          }
        });
        
        
        
        userLeftPanel.add(userDeleteButton);

        userPanel.add(userLeftPanel, java.awt.BorderLayout.WEST);

        mainRightPanel.add(new RoundedPanel(userPanel));
        
        
        
        
        managerPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        managerPanel.setOpaque(false);
        managerPanel.setPreferredSize(new java.awt.Dimension(117, 80));
        managerPanel.setLayout(new java.awt.BorderLayout());

        managerListScrollPane.setBorder(null);
        managerListScrollPane.setOpaque(false);
        managerListScrollPane.getVerticalScrollBar().setUI(new SheepScrollbarUI());
        ManagerListModel managerUserListModel =new ManagerListModel(workSpace);
        userList1.setModel(managerUserListModel);
        userList1.setPreferredSize(new java.awt.Dimension(33, 100));
        userList1.setOpaque(false);
        managerListScrollPane.setViewportView(userList1);

        managerPanel.add(new RoundedPanel(managerListScrollPane,5,5,5,5), java.awt.BorderLayout.CENTER);

        managerLeftPanel.setPreferredSize(new java.awt.Dimension(100, 31));
        managerLeftPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 10));
        managerLeftPanel.setOpaque(false);
        managerLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        managerLabel.setForeground(new java.awt.Color(255, 255, 255));
        managerLabel.setText("Responsable :");
        managerLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        managerLeftPanel.add(managerLabel);
        
        managerAddButton1.setText("+");
        managerAddButton1.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            userChooserTopPanel.setPanelMode(PanelMode.MANAGER);
            Component[] comp ={userList1};
            userChooserTopPanel.setRepaintComponent(comp);
            userChooserTopPanel.repaintTable();
            userChooserTopPanel.setVisible(true);
          }
        });
        managerLeftPanel.add(managerAddButton1);

        managerDeleteButton1.setText("-");
        managerDeleteButton1.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
             if(userList1.getSelectedValues().length!=0 && 
                     userList1.getSelectedIndex() < userList1.getModel().getSize()){           
               ManagerListModel  model = (ManagerListModel)userList1.getModel();
               if(workSpace.getCurrentProject() instanceof Project)
                 ((Project)workSpace.getCurrentProject()).getManagers().remove( 
                       model.getWorker(userList1.getSelectedIndex()));
               //model.deleteWorker(model.getWorker(userList.getSelectedIndex()));
               userChooserTopPanel.setPanelMode(PanelMode.MANAGER);
               Component[] comp ={userList1};
               userChooserTopPanel.setRepaintComponent(comp);
               userChooserTopPanel.repaintTable();
               userList.repaint();
             }
          }
        });        
        
        managerLeftPanel.add(managerDeleteButton1);

        managerPanel.add(managerLeftPanel, java.awt.BorderLayout.WEST);

        mainRightPanel.add(new RoundedPanel(managerPanel));

   

        imagePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        imagePanel.setOpaque(false);
        imagePanel.setPreferredSize(new java.awt.Dimension(102, 80));
        imagePanel.setLayout(new java.awt.BorderLayout());

        imageLeftPanel.setOpaque(false);
        imageLeftPanel.setPreferredSize(new java.awt.Dimension(100, 31));
        imageLeftPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 10));

        ImageLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        ImageLabel.setForeground(new java.awt.Color(255, 255, 255));
        ImageLabel.setText("Image :");
        ImageLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        imageLeftPanel.add(ImageLabel);

        imageModifButton.setText("Modifier");
        imageModifButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            JFileChooser choix = new JFileChooser();
            MonFiltre mfi = new MonFiltre(
                    new String[]{"gif","png", "jpeg", "jpg", "bmp"},
                    "les fichiers image (*.gif, *.png, *.jpeg, *.bmp)");
            choix. addChoosableFileFilter(mfi);
             
            int retour = choix.showOpenDialog(ProjectNewPanel.this);
            if(retour == JFileChooser.APPROVE_OPTION) {
           // un fichier a été choisi ( sortie par OK)
             choix.getSelectedFile().getName();       // nom du fichier choisi

             choix.getSelectedFile().getAbsolutePath();// chemin absolu du fichier choisi
             if (workSpace.getCurrentProject() instanceof Project){
               ((Project)workSpace.getCurrentProject()).setPicturePath(choix.getSelectedFile().getAbsolutePath());
             }
             try{
              jXImagePanel.setImage(ResizingImage.resize(80, 80,choix.getSelectedFile().getAbsolutePath()));
              ((Project)workSpace.getCurrentProject()).setPictures(ResizingImage.resize(80, 80,choix.getSelectedFile().getAbsolutePath()));
            }catch(Exception e){}

             
            }
          }
        });
        imageLeftPanel.add(imageModifButton);

        imagePanel.add(imageLeftPanel, java.awt.BorderLayout.WEST);

        jXImagePanel.setBackground(new java.awt.Color(255, 255, 255));
        jXImagePanel.setPreferredSize(new Dimension(60,60));
        try{
          //jXImagePanel.setImage(ResizingImage.resize(80, 80,"src/resources/images/2674mouton.jpg"));
        }catch(Exception e){}
        imagePanel.add(new RoundedPanel(jXImagePanel,5,5,5,5), java.awt.BorderLayout.EAST);

        mainRightPanel.add(new RoundedPanel(imagePanel));

        rightPanel.add(mainRightPanel, java.awt.BorderLayout.CENTER);        

        
        innerPanel.add((rightPanel));  

        
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
        
        ////////////////////////
        // 3EME PAGE
        thirdPanel = new DropShadowPanel();
        thirdPanel.setOpaque(false);                
        thirdPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 10, 1, 10));
        thirdPanel.setOpaque(false);
        thirdPanel.setLayout(new java.awt.BorderLayout());
        thirdPanel.setBounds(1040, 0, 480, 500);
        thirdPanel.setPreferredSize(new java.awt.Dimension(480, 500));
        
        
        mainThirdPanel = new javax.swing.JPanel();
        titleThirdPanel = new javax.swing.JPanel();
        titleThirdLabel = new javax.swing.JLabel();
        folderPanel = new javax.swing.JPanel();
        folderLabel = new javax.swing.JLabel();
        folderModifButton = new ActionButton();
        folderTextField = new javax.swing.JTextField();
        taskTreePanel = new javax.swing.JPanel();
        taskTreeLeftPanel = new javax.swing.JPanel();
        taskLabel = new javax.swing.JLabel();
        taskGraphButton = new ActionButton();
        taskGantButton = new ActionButton();
        taskInfosButton = new ActionButton();
        taskScrollPane = new javax.swing.JScrollPane();
        taskTree = new javax.swing.JTree();


    
    
        
        
        mainThirdPanel.setOpaque(false);
        VerticalLayout verticalLayout3 = new VerticalLayout();
        verticalLayout3.setGap(15);
        mainThirdPanel.setLayout(verticalLayout3);
        
        titleThirdPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        titleThirdPanel.setOpaque(false);
        titleThirdPanel.setPreferredSize(new java.awt.Dimension(258, 30));
        titleThirdPanel.setLayout(new java.awt.BorderLayout());

        titleThirdLabel.setFont(new java.awt.Font("Times New Roman", 1, 24));
        titleThirdLabel.setForeground(new java.awt.Color(255, 255, 255));
        titleThirdLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        titleThirdLabel.setText("PROJETS");
        titleThirdPanel.add(titleThirdLabel, java.awt.BorderLayout.CENTER);

        mainThirdPanel.add(titleThirdPanel);

        
        
        folderPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        folderPanel.setOpaque(false);
        folderPanel.setLayout(new java.awt.BorderLayout());

        folderLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        folderLabel.setForeground(new java.awt.Color(255, 255, 255));
        folderLabel.setText("Repertoire :");
        folderLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        folderPanel.add(folderLabel, java.awt.BorderLayout.LINE_START);

        folderModifButton.setText("Modifier");
        folderModifButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            JFileChooser choix = new JFileChooser();
            choix.setFileSelectionMode(
                  JFileChooser.DIRECTORIES_ONLY);
             
            int retour = choix.showOpenDialog(ProjectNewPanel.this);
            if(retour == JFileChooser.APPROVE_OPTION) {
           // un fichier a été choisi ( sortie par OK)
             choix.getSelectedFile().getName();       // nom du fichier choisi

              folderTextField.setText(choix.getSelectedFile().getAbsolutePath());// chemin absolu du fichier choisi
              
              if(workSpace.getCurrentProject() instanceof Project)
                 ((Project)workSpace.getCurrentProject()).setProjectPath(choix.getSelectedFile().getAbsolutePath());
             
            }
            
          }
        });
        folderPanel.add(folderModifButton, java.awt.BorderLayout.LINE_END);

        folderTextField.setText("C:\\AuBistrot\\");
        folderTextField.setFont(new java.awt.Font("Times New Roman", 1, 14));
        folderTextField.setBorder(BorderFactory.createEmptyBorder());
        folderTextField.setOpaque(false);
        folderTextField.setPreferredSize(new java.awt.Dimension(296, 20));        
        folderPanel.add(new RoundedPanel(folderTextField,0,0,0,0), java.awt.BorderLayout.CENTER);

        mainThirdPanel.add(new RoundedPanel(folderPanel));

        taskTreePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        taskTreePanel.setOpaque(false);
        taskTreePanel.setPreferredSize(new java.awt.Dimension(150, 230));
        taskTreePanel.setLayout(new java.awt.BorderLayout());

        taskTreeLeftPanel.setPreferredSize(new java.awt.Dimension(100, 31));
        taskTreeLeftPanel.setOpaque(false);
        taskTreeLeftPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 20));

        taskLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        taskLabel.setForeground(new java.awt.Color(255, 255, 255));
        taskLabel.setText("Taches :");
        taskLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        taskTreeLeftPanel.add(taskLabel);

        taskGraphButton.setText("Graphe");
        taskGraphButton.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
             if (taskTree.getLastSelectedPathComponent() != null)
              TransitionManager.showProjectGraphEdit();
            }
          });
        taskTreeLeftPanel.add(taskGraphButton);

        taskGantButton.setText("Gant");
        taskGantButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            TransitionManager.showGanttEdit();
          }
        });
        
        taskTreeLeftPanel.add(taskGantButton);

        taskInfosButton.setText("Infos...");
        //taskTreeLeftPanel.add(taskInfosButton);

        taskTreePanel.add(taskTreeLeftPanel, java.awt.BorderLayout.WEST);

        taskScrollPane.setBorder(null);
        taskScrollPane.setViewportView(taskTree);

        
        taskTree.addTreeSelectionListener(new TreeSelectionListener() {

          public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode)
                               taskTree.getLastSelectedPathComponent();
            System.out.println("bhhhhhhhhhhhhh");
            /* if nothing is selected */ 
                if (node == null) return;

            /* retrieve the node that was selected */ 
                String name = (String)node.getUserObject();
                for ( Task t : workSpace.getCurrentProject().getTaskList(true, true)){
                  if(t.getName().equals(name)){
                    workSpace.setCurrentTask(t);
                    refreshInner();
                    return;
                  }
                }
          }
        });
        taskScrollPane.setOpaque(false);
        taskScrollPane.getVerticalScrollBar().setUI(new SheepScrollbarUI());
        taskTreePanel.add(new RoundedPanel(taskScrollPane,5,5,5,5), java.awt.BorderLayout.CENTER);

        mainThirdPanel.add(new RoundedPanel(taskTreePanel));

        thirdPanel.add(mainThirdPanel, java.awt.BorderLayout.CENTER);        

        innerPanel.add((thirdPanel));  
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
        
        //////////////////////////
        // 4EME PAGE
        fourthPanel = new DropShadowPanel();
        fourthPanel.setOpaque(false);                
        fourthPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 10, 1, 10));
        fourthPanel.setOpaque(false);
        fourthPanel.setLayout(new java.awt.BorderLayout());
        fourthPanel.setBounds(1560, 0, 480, 500);
        fourthPanel.setPreferredSize(new java.awt.Dimension(480, 500));       
        
        mainFourthPanel = new javax.swing.JPanel();
        titleFourthPanel = new javax.swing.JPanel();
        titleFourthLabel = new javax.swing.JLabel();
        beginDateTaskPanel = new javax.swing.JPanel();
        beginDateTaskLabel = new javax.swing.JLabel();
        beginDateTaskXDatePicker = new org.jdesktop.swingx.JXDatePicker();
        endDateTaskPanel = new javax.swing.JPanel();
        endDateTaskLabel = new javax.swing.JLabel();
        endDateTaskXDatePicker = new org.jdesktop.swingx.JXDatePicker();
        durationTaskPanel = new javax.swing.JPanel();
        durationTaskLabel = new javax.swing.JLabel();
        durationTaskModifButton = new ActionButton();
        durationTaskTextField = new javax.swing.JTextField();
        UserTaskPanel = new javax.swing.JPanel();
        UserTaskLeftPanel = new javax.swing.JPanel();
        UserTaskLabel = new javax.swing.JLabel();
        UserTaskAddButton = new ActionButton("+",new Dimension (25,25));
        UserTaskRemButton = new ActionButton("+",new Dimension (25,25));
        UserTaskOpenButton = new ActionButton("+",new Dimension (25,25));
        UserTaskScrollPane = new javax.swing.JScrollPane();
        UserTaskList = new javax.swing.JList();
        documentPanel = new javax.swing.JPanel();
        documentLeftPanel = new javax.swing.JPanel();
        documentLabel = new javax.swing.JLabel();
        documentAddButton = new ActionButton("+",new Dimension (25,25));
        documentRemButton = new ActionButton("+",new Dimension (25,25));
        documentOpenButton = new ActionButton("+",new Dimension (25,25));
        documentScrollPane = new javax.swing.JScrollPane();
        documentList = new javax.swing.JList();

        mainFourthPanel.setOpaque(false);
        VerticalLayout verticalLayout4 = new VerticalLayout();
        verticalLayout4.setGap(15);
        mainFourthPanel.setLayout(verticalLayout4);        

        titleFourthPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        titleFourthPanel.setOpaque(false);
        titleFourthPanel.setPreferredSize(new java.awt.Dimension(258, 30));
        titleFourthPanel.setLayout(new java.awt.BorderLayout());

        titleFourthLabel.setFont(new java.awt.Font("Times New Roman", 1, 24));
        titleFourthLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        titleFourthLabel.setText("DETAILS : Taches xxx");
        if (workSpace.getCurrentTask()!=null)
          titleFourthLabel.setText("DETAILS : "+workSpace.getCurrentTask().getName());
        titleFourthLabel.setForeground(new java.awt.Color(255, 255, 255));
        titleFourthPanel.add(titleFourthLabel, java.awt.BorderLayout.CENTER);

        mainFourthPanel.add(titleFourthPanel);

        GridLayout gridLayout3 = new GridLayout(3,1);
        //gridLayout3.setVgap(10);
        JPanel tempDatePanel = new JPanel(gridLayout3);
        tempDatePanel.setPreferredSize(new java.awt.Dimension(296, 110));
        tempDatePanel.setOpaque(false);
        
        beginDateTaskPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 8, 1));
        beginDateTaskPanel.setOpaque(false);
        beginDateTaskPanel.setPreferredSize(new java.awt.Dimension(117, 20));
        beginDateTaskPanel.setLayout(new java.awt.BorderLayout());

        beginDateTaskLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        beginDateTaskLabel.setText("Date de début :");
        beginDateTaskLabel.setForeground(new java.awt.Color(255, 255, 255));
        beginDateTaskLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        beginDateTaskPanel.add(beginDateTaskLabel, java.awt.BorderLayout.LINE_START);

        if (workSpace.getCurrentTask()!=null)
          beginDateTaskXDatePicker.setDate(workSpace.getCurrentTask().getActualBeginTime().getTime());
        
        beginDateTaskXDatePicker.setEnabled(false);
        
        beginDateTaskXDatePicker.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
          Calendar calTemp = Calendar.getInstance();
          calTemp.setTime(beginDateTaskXDatePicker.getDate());
          workSpace.getCurrentTask().setActualBeginTime(calTemp, true);//.getActualBeginTime().setTime(beginDateTaskXDatePicker.getDate());
          //workSpace.getCurrentProject().updateProject();
          workSpace.getCurrentTask().setEarliestBeginTime(calTemp, true);
          workSpace.getCurrentTask().setLatestBeginTime(calTemp, true);
//          Task taskTemp = workSpace.getCurrentTask().getGraph().parse();
//          Graph graph = taskTemp.getGraph();    
//          try {
//            graph.criticalPath(true, Direction.BOTH);
//          } catch (CyclicGraphException ex) {}
            
          if (workSpace.getCurrentProject()!=null)
            beginDatePicker.setDate(workSpace.getCurrentProject().getActualBeginTime().getTime());
          }
        });  
        beginDateTaskPanel.add(beginDateTaskXDatePicker, java.awt.BorderLayout.CENTER);

        tempDatePanel.add(beginDateTaskPanel);

        endDateTaskPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 8, 1));
        endDateTaskPanel.setOpaque(false);
        endDateTaskPanel.setPreferredSize(new java.awt.Dimension(117, 20));
        endDateTaskPanel.setLayout(new java.awt.BorderLayout());

        endDateTaskLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        endDateTaskLabel.setText("Date de fin");
        endDateTaskLabel.setForeground(new java.awt.Color(255, 255, 255));
        endDateTaskLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        endDateTaskPanel.add(endDateTaskLabel, java.awt.BorderLayout.LINE_START);
        if (workSpace.getCurrentTask()!=null)
          endDateTaskXDatePicker.setDate(workSpace.getCurrentTask().getActualEndTime().getTime());
        endDateTaskXDatePicker.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
          Calendar calTemp = Calendar.getInstance();
          calTemp.setTime(endDateTaskXDatePicker.getDate());
          workSpace.getCurrentTask().setActualEndTime(calTemp, true);//getActualEndTime().setTime(endDateTaskXDatePicker.getDate());
          
//          Task taskTemp = workSpace.getCurrentTask().getGraph().parse();
//          Graph graph = taskTemp.getGraph();    
//          try {
            //workSpace.getCurrentTask().getGraph().criticalPath(true);//, Direction.BOTH);
//          } catch (CyclicGraphException ex) {}

            if (workSpace.getCurrentProject()!=null)
              endDatePicker.setDate(workSpace.getCurrentProject().getActualEndTime().getTime());
          }
        });  
        endDateTaskPanel.add(endDateTaskXDatePicker, java.awt.BorderLayout.CENTER);

        tempDatePanel.add(endDateTaskPanel);

        durationTaskPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 5, 1));
        durationTaskPanel.setOpaque(false);
        durationTaskPanel.setPreferredSize(new java.awt.Dimension(117, 20));
        durationTaskPanel.setLayout(new java.awt.BorderLayout());

        durationTaskLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        durationTaskLabel.setText("Durée");
        durationTaskLabel.setForeground(new java.awt.Color(255, 255, 255));
        durationTaskLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        durationTaskPanel.add(durationTaskLabel, java.awt.BorderLayout.LINE_START);

        durationTaskModifButton.setText("Modifier");
        durationTaskModifButton.setOpaque(false);
        durationTaskModifButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
          }
        });
        durationTaskPanel.add(durationTaskModifButton, java.awt.BorderLayout.LINE_END);

        durationTaskTextField.setText("C:\\AuBistrot\\");
        durationTaskTextField.setOpaque(false);
        durationTaskTextField.setBorder(BorderFactory.createEmptyBorder());
        durationTaskPanel.add(new RoundedPanel(durationTaskTextField,0,0,0,0), java.awt.BorderLayout.CENTER);

        tempDatePanel.add(durationTaskPanel);
        mainFourthPanel.add(new RoundedPanel(tempDatePanel));

        UserTaskPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        UserTaskPanel.setOpaque(false);
        UserTaskPanel.setPreferredSize(new java.awt.Dimension(150, 165));
        UserTaskPanel.setLayout(new java.awt.BorderLayout());

        UserTaskLeftPanel.setOpaque(false);
        UserTaskLeftPanel.setPreferredSize(new java.awt.Dimension(100, 31));
        UserTaskLeftPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 5));

        UserTaskLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        UserTaskLabel.setText("Participants :");
        UserTaskLabel.setForeground(new java.awt.Color(255, 255, 255));
        UserTaskLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        UserTaskLeftPanel.add(UserTaskLabel);

        UserTaskAddButton.setText("+");
        UserTaskAddButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            userChooserTopPanel.setPanelMode(PanelMode.TASK);
            Component[] comp ={UserTaskList,
              workSpace.getCurrentProject() == workSpace.getCurrentTask() ? userList : null};          
            userChooserTopPanel.setRepaintComponent(comp);
            userChooserTopPanel.repaintTable();
            userChooserTopPanel.setVisible(true);
            UserTaskList.repaint();
            userList.repaint();
          }
        });
        UserTaskLeftPanel.add(UserTaskAddButton);

        UserTaskRemButton.setText("-");
        UserTaskRemButton.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
             if(UserTaskList.getSelectedValues().length!=0 && 
                     UserTaskList.getSelectedIndex() < UserTaskList.getModel().getSize()){           
               UserTaskListModel  model = (UserTaskListModel)UserTaskList.getModel();
               workSpace.getCurrentTask().getWorkersList().remove( 
                       model.getWorker(UserTaskList.getSelectedIndex()));
               //model.deleteWorker(model.getWorker(userList.getSelectedIndex()));
               userChooserTopPanel.setPanelMode(PanelMode.TASK);
               Component[] comp ={UserTaskList,
                 workSpace.getCurrentProject() == workSpace.getCurrentTask() ? userList : null};
               userChooserTopPanel.setRepaintComponent(comp);
               userChooserTopPanel.repaintTable();
               UserTaskList.repaint();
               userList.repaint();
             }
          }
        });
        UserTaskLeftPanel.add(UserTaskRemButton);

        UserTaskOpenButton.setText("O");
        UserTaskLeftPanel.add(UserTaskOpenButton);

        UserTaskPanel.add(UserTaskLeftPanel, java.awt.BorderLayout.WEST);

        UserTaskScrollPane.setBorder(null);
        UserTaskScrollPane.setOpaque(false);
        UserTaskScrollPane.getVerticalScrollBar().setUI(new SheepScrollbarUI());
        UserTaskListModel ParticipantTaskListModel =new UserTaskListModel(workSpace);
        UserTaskList.setModel(ParticipantTaskListModel); 
        UserTaskList.setName("task");
        UserTaskList.setOpaque(false);
        UserTaskScrollPane.setViewportView(UserTaskList);

        UserTaskPanel.add(new RoundedPanel(UserTaskScrollPane,5,5,5,5), java.awt.BorderLayout.CENTER);

        mainFourthPanel.add(new RoundedPanel(UserTaskPanel));

        documentPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        documentPanel.setOpaque(false);
        documentPanel.setPreferredSize(new java.awt.Dimension(150, 75));
        documentPanel.setLayout(new java.awt.BorderLayout());

        documentLeftPanel.setOpaque(false);
        documentLeftPanel.setPreferredSize(new java.awt.Dimension(100, 31));
        documentLeftPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 5));

        documentLabel.setFont(new java.awt.Font("Times New Roman", 1, 14));
        documentLabel.setText("Documents :");
        documentLabel.setForeground(new java.awt.Color(255, 255, 255));
        documentLabel.setPreferredSize(new java.awt.Dimension(100, 17));
        documentLeftPanel.add(documentLabel);

        documentAddButton.setText("+");
        documentAddButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {

          }
        });
        documentLeftPanel.add(documentAddButton);

        documentRemButton.setText("-");
        documentRemButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {

          }
        });
        documentLeftPanel.add(documentRemButton);

        documentOpenButton.setText("O");
        documentLeftPanel.add(documentOpenButton);

        documentPanel.add(documentLeftPanel, java.awt.BorderLayout.WEST);

        documentScrollPane.setBorder(null);
        documentScrollPane.setOpaque(false);
        documentScrollPane.getVerticalScrollBar().setUI(new SheepScrollbarUI());
        documentList.setModel(new javax.swing.AbstractListModel() {
          String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
          public int getSize() { return strings.length; }
          public Object getElementAt(int i) { return strings[i]; }
        });
        documentList.setOpaque(false);
        documentScrollPane.setViewportView(documentList);

        documentPanel.add(new RoundedPanel(documentScrollPane,5,5,5,5), java.awt.BorderLayout.CENTER);

        //mainFourthPanel.add(new RoundedPanel(documentPanel));

        fourthPanel.add(mainFourthPanel, java.awt.BorderLayout.CENTER);        
   
        innerPanel.add((fourthPanel)); 
        
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
        
        //////////////////////////
        // 5EME PAGE        
        fifthPanel = new DropShadowPanel();
        fifthPanel.setOpaque(false);                
        fifthPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 10, 1, 10));
        fifthPanel.setOpaque(false);
        fifthPanel.setLayout(new java.awt.BorderLayout());
        fifthPanel.setBounds(2080, 0, 960, 500);
        fifthPanel.setPreferredSize(new java.awt.Dimension(960, 500));  
        
        mainFifthPanel = new javax.swing.JPanel();
        titleFifthPanel = new javax.swing.JPanel();
        titleFifthLabel = new javax.swing.JLabel();
        dependancePanel = new javax.swing.JPanel();
        dependanceSouthPanel = new javax.swing.JPanel();
        dependanceSouthLeftPanel = new javax.swing.JPanel();
        dependanceSouthDefCurrentButton = new ActionButton("", new Dimension(150,25));
        dependanceSouthCenterPanel = new javax.swing.JPanel();
        dependanceSouthUsersButton = new ActionButton();
        dependanceSouthGrapheButton = new ActionButton();
        dependanceSouthGantButton = new ActionButton();
        dependanceSouthRightPanel = new javax.swing.JPanel();
        dependanceSouthSupertaskButton = new ActionButton();
        dependanceScrollPane = new javax.swing.JScrollPane();
        dependanceTable = new JXTable();
        dependanceLeftPanel = new javax.swing.JPanel();
        documentLabel1 = new javax.swing.JLabel();
        dependanceLeftAddButton = new ActionButton();
        dependanceLeftRemButton = new ActionButton();
        dependanceLeftEditButton = new ActionButton();

        mainFifthPanel.setOpaque(false);
        VerticalLayout verticalLayout5 = new VerticalLayout();
        verticalLayout5.setGap(15);
        mainFifthPanel.setLayout(verticalLayout5);  
        

        titleFifthPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        titleFifthPanel.setOpaque(false);
        titleFifthPanel.setPreferredSize(new java.awt.Dimension(258, 30));
        titleFifthPanel.setLayout(new java.awt.BorderLayout());


        titleFifthLabel.setFont(new java.awt.Font("Times New Roman", 1, 24));
        titleFifthLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        titleFifthLabel.setText("Sous taches : Taches xxx");
        titleFifthLabel.setForeground(new java.awt.Color(255, 255, 255));
        titleFifthPanel.add(titleFifthLabel, java.awt.BorderLayout.CENTER);

        mainFifthPanel.add(titleFifthPanel);

        dependancePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        dependancePanel.setOpaque(false);
        dependancePanel.setPreferredSize(new java.awt.Dimension(150, 290));
        dependancePanel.setLayout(new java.awt.BorderLayout());

        dependanceSouthPanel.setOpaque(false);
        dependanceSouthPanel.setPreferredSize(new java.awt.Dimension(100, 31));
        dependanceSouthPanel.setLayout(new java.awt.BorderLayout());

        dependanceSouthLeftPanel.setOpaque(false);

        dependanceSouthDefCurrentButton.setText("Definir comme courante");
        dependanceSouthDefCurrentButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
              Task t = workSpace.getSelectedTask();
              if(t!=null)
               workSpace.setCurrentTask(t);
               refreshInner();     
          }
        });
        dependanceSouthLeftPanel.add(dependanceSouthDefCurrentButton);

        //dependanceSouthPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1));
        dependanceSouthPanel.add(dependanceSouthLeftPanel, java.awt.BorderLayout.WEST);
        
        dependanceSouthCenterPanel.setOpaque(false);

        dependanceSouthUsersButton.setText("Participants");
        dependanceSouthUsersButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
           userChooserTopPanel.setPanelMode(PanelMode.TASK);
            Component[] comp ={UserTaskList,
              workSpace.getCurrentProject() == workSpace.getCurrentTask() ? userList : null};          
            userChooserTopPanel.setRepaintComponent(comp);
            userChooserTopPanel.repaintTable();
            userChooserTopPanel.setVisible(true);
            UserTaskList.repaint();
            userList.repaint();
          }
        });         
        
        dependanceSouthCenterPanel.add(dependanceSouthUsersButton);

        dependanceSouthGrapheButton.setText("Graphe");
        dependanceSouthGrapheButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
              Task t = workSpace.getSelectedTask();
              if(t!=null){
                 workSpace.setCurrentTask(t);  
                 TransitionManager.showProjectGraphEdit();
              }
          }
        });        
        
        
        dependanceSouthCenterPanel.add(dependanceSouthGrapheButton);
 
        dependanceSouthGantButton.setText("Gant");
        dependanceSouthGantButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
              Task t = workSpace.getSelectedTask();
              if(t!=null){
                 workSpace.setCurrentTask(t);
                 TransitionManager.showGanttEdit();
              }
          }
        });    
        dependanceSouthCenterPanel.add(dependanceSouthGantButton);

        dependanceSouthPanel.add(dependanceSouthCenterPanel, java.awt.BorderLayout.CENTER);

        dependanceSouthRightPanel.setOpaque(false);

        dependanceSouthSupertaskButton.setText("Tache mère");
        dependanceSouthSupertaskButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {

              Task t = workSpace.getCurrentTask().getSuperTask();
              if(t!=null)
               workSpace.setCurrentTask(t);
               refreshInner();

          }
        });
        dependanceSouthRightPanel.add(dependanceSouthSupertaskButton);

        dependanceSouthPanel.add(dependanceSouthRightPanel, java.awt.BorderLayout.EAST);

        dependancePanel.add(dependanceSouthPanel, java.awt.BorderLayout.SOUTH);

        dependanceScrollPane.setBorder(null);
        dependanceScrollPane.setOpaque(false);
        dependanceScrollPane.setPreferredSize(new Dimension(800, 400));
        /*if (workSpace.getCurrentTask()!=null){
          dependanceTable.setModel(new javax.swing.table.DefaultTableModel(
          workSpace.getCurrentTask().getTaskTab(false,false),
          new String [] {
            "Nom", "Date de début", "Date de fin", "Taches nécessaires"
          }
        ));        
        }else{
        dependanceTable.setModel(new javax.swing.table.DefaultTableModel(
          new Object [][] {
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null}
          },
          new String [] {
            "Nom", "Date de début", "Date de fin", "Taches nécessaires"
          }
        ));
        }*/
 

        
    UserCellRenderer render = new UserCellRenderer();
    render.setBorderHeight(false);
    Object headers[] = {"Nom", "Date de début", "Date de fin", "Taches nécessaires" };  
    dependanceTable = new JXTable();
    dependanceTable.setShowVerticalLines(false);
    dependanceTable.setGridColor(Color.LIGHT_GRAY);
    usersTableModel = new TaskManualCreateTableModel (headers, workSpace.getCurrentTask()== null ?
    new LinkedList<Task> () : workSpace.getCurrentTask().getTaskList(false, false));
    
    dependanceTable.setModel(usersTableModel);
    TaskManualCreateTableModel.setTableHeaders(dependanceTable, usersTableModel.getHeaders());

    dependanceTable.setDefaultRenderer(Object.class, render);
    dependanceTable.setColumnControlVisible(true);
    dependanceTable.setRowHeight(34);
    dependanceTable.setFocusable(false);
    dependanceTable.packAll();
    dependanceTable.setColumnSelectionAllowed(false);
    dependanceTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dependanceTable.setEditable(false);
            
            
    dependanceTable.addMouseListener(new MouseListener(){

      public void mouseClicked(MouseEvent e) {
        if (dependanceTable.getSelectedRow()>=0){
         Task t  = usersTableModel.getList().get(dependanceTable.getSelectedRow());
         workSpace.setSelectedTask(t);
         System.out.println(t.getName());
        if(e.getClickCount()==2) {
          manualEditPanel.setVisible(true);
        }
        }
      }

      public void mousePressed(MouseEvent e) {}
      public void mouseReleased(MouseEvent e) {}
      public void mouseEntered(MouseEvent e) {}
      public void mouseExited(MouseEvent e) {}
    });        
        
        
        
        
        
        
        
        dependanceScrollPane.getVerticalScrollBar().setUI(new SheepScrollbarUI());
        dependanceScrollPane.setViewportView(dependanceTable);

        manualEditPanel = new ProjectManualEditPanel(this.workSpace);
        r = new RoundedPanel(manualEditPanel);
        Component[] comp ={r,this }; 
        manualEditPanel.setRepaintComponent(comp);
        
        
        JXPanel manualEditSatckPanel = new JXPanel(new StackLayout());
        manualEditSatckPanel.setOpaque(false);
        manualEditSatckPanel. add(new RoundedPanel(dependanceScrollPane), StackLayout.TOP);
        manualEditPanel.setVisible2(false);
        r = new RoundedPanel(manualEditPanel);
        r.setVisible(false);
        manualEditSatckPanel.add(r,StackLayout.TOP );  
        
        dependancePanel.add(manualEditSatckPanel, java.awt.BorderLayout.CENTER);

        dependanceLeftPanel.setOpaque(false);
        dependanceLeftPanel.setPreferredSize(new java.awt.Dimension(100, 31));
        dependanceLeftPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 10));

        documentLabel1.setFont(new java.awt.Font("Times New Roman", 1, 14));
        documentLabel1.setText("Opérations :");
        documentLabel1.setForeground(new java.awt.Color(255, 255, 255));
        documentLabel1.setPreferredSize(new java.awt.Dimension(100, 17));
        dependanceLeftPanel.add(documentLabel1);

        dependanceLeftAddButton.setText("+");
        dependanceLeftAddButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            manualEditPanel.setMode(TaskCreateMode.CREATE);
            manualEditPanel.setVisible(true);
            r.setVisible(true);
          }
        });
        dependanceLeftPanel.add(dependanceLeftAddButton);

        dependanceLeftRemButton.setText("-");
        dependanceLeftRemButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
           
            
            if (workSpace.getCurrentTask()!=null){
              LinkedList<Task> list= workSpace.getCurrentTask().getTaskList(false, false);
              list.remove(workSpace.getCurrentTask());
              if (workSpace.getSelectedTask()!=null){
                list.remove(workSpace.getSelectedTask());
                workSpace.getCurrentTask().getGraph().removeVertex(workSpace.getSelectedTask());
              }
              usersTableModel.setData(list);
              dependanceTable.setModel(usersTableModel);
              dependanceTable.repaint();
          }
            
          }
        });
        dependanceLeftPanel.add(dependanceLeftRemButton);

        dependanceLeftEditButton.setText("Editer");
        dependanceLeftEditButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (workSpace.getSelectedTask()!=null){
              manualEditPanel.setMode(TaskCreateMode.EDIT);
              manualEditPanel.setVisible(true);
              r.setVisible(true);
            }
          }
        });        
        dependanceLeftPanel.add(dependanceLeftEditButton);

        dependancePanel.add(dependanceLeftPanel, java.awt.BorderLayout.WEST);


        
        mainFifthPanel.add(new RoundedPanel(dependancePanel));

         
        
  

        
        
        fifthPanel.add(mainFifthPanel, java.awt.BorderLayout.CENTER);       
        
        innerPanel.add(fifthPanel, java.awt.BorderLayout.CENTER);

        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
              
        //Ajout au panel principal
        taskPanel.add(BorderLayout.CENTER, innerPanel);
              
        JPanel bottomPanel = new JPanel ( new BorderLayout());
        bottomPanel.setOpaque(false);
        bottomPanel.setBorder(BorderFactory.createEmptyBorder(10,65,0,60));
        nextButton = new ActionButton();
        nextButton.setText("Suite >>");
        nextButton.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (currentScreen == ScreenType.FIRST){
              leftFirstAnimator.start();
              precButton.setVisible(true);
              currentScreen = ScreenType.SECOND;
            }else if (currentScreen == ScreenType.SECOND){
              leftSecondAnimator.start();
              //nextButton.setVisible(false);
              currentScreen = ScreenType.THIRD;
            }else if (currentScreen == ScreenType.THIRD){
              leftThirdAnimator.start();
              nextButton.setVisible(false);
              currentScreen = ScreenType.FOURTH;
            }
            
          }
        });
        bottomPanel.add(nextButton, BorderLayout.EAST);
        
        precButton = new ActionButton();
        precButton.setText("<<Précédent");
        precButton.setVisible(false);
        precButton.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (currentScreen == ScreenType.SECOND){
              rightFirstAnimator.start();
              precButton.setVisible(false);
              currentScreen = ScreenType.FIRST;           
            }else if (currentScreen == ScreenType.THIRD){
              rightSecondAnimator.start();
              //nextButton.setVisible(true);
              currentScreen = ScreenType.SECOND;
            }else if (currentScreen == ScreenType.FOURTH){
              rightThirdAnimator.start();
              nextButton.setVisible(true);
              currentScreen = ScreenType.THIRD;
            }
            
          }
        });      
        bottomPanel.add(precButton, BorderLayout.WEST);      
        
        
        taskPanel.add(bottomPanel, BorderLayout.SOUTH);        
        
        // Création de marge
        taskPanel.add(BorderLayout.WEST, Box.createHorizontalStrut(60));
        taskPanel.add(BorderLayout.EAST, Box.createHorizontalStrut(60));

        return taskPanel;
    }
        
        
        
    private JPanel buildProjectVisualisationPanel() {
        // Nouveau panel
        JPanel taskPanel = new JPanel(new BorderLayout());
        taskPanel.setOpaque(false);
        // Ajout d'un titre floutés
        taskPanel.add(BorderLayout.NORTH, new BackgroundMenuTitle(
                Bundles.getMessage(getClass(), "TXT_VisualisationProjet")));
        // Sous panel
        buttonPanel = new JPanel();
        buttonPanel.setOpaque(false);
        // Ajout au panel principal
        taskPanel.add(buttonPanel, BorderLayout.CENTER);
        // Création de marge
        taskPanel.add(BorderLayout.WEST, Box.createHorizontalStrut(60));
        taskPanel.add(BorderLayout.EAST, Box.createHorizontalStrut(60));
        return taskPanel;
    }
    

    private void computeShadow() {
        // Conversion de degre en radian
        double rads = Math.toRadians(shadowDirection);
        // Calcul des projection en X et Y
        shadowOffsetX = (float) Math.cos(rads) * shadowDistance;
        shadowOffsetY = (float) Math.sin(rads) * shadowDistance;
    }

    private JButton createButton(String name, String description, String image) {
        return new TaskButton(name, description, image);
    }
  

    void setTasks() {
        // On verifie aue le panel est vide
        buttonPanel.removeAll();
        // layout contraint
        buttonPanel.setLayout(new GridBagLayout());
        // Positionnement des bouttons
        int counter = 0;
        JButton button;
        buttonPanel.add(button = createButton("Afficher Graphe", "graphes des dépendances entre taches", "/resources/images/task-view-photos.png"),
                        new GridBagConstraints(counter % 2, counter / 2,
                                               1, 1,
                                               0.5, 0.5,
                                               GridBagConstraints.NORTHWEST,
                                               GridBagConstraints.HORIZONTAL,
                                               new Insets(0, 0, 0, (counter + 1) % 2 != 0 ? 30 : 0),
                                               0, 0));
        // Click
        button.addActionListener(new ActionListener(){
          @Override
          public void actionPerformed(ActionEvent e) {
            TransitionManager.showProjectGraphEdit();
          }      
        });
        counter++;
        buttonPanel.add(button = createButton("Afficher GANT", "Diagramme de GANT", "/resources/images/task-create-trip.png"),
                        new GridBagConstraints(counter % 2, counter / 2,
                                               1, 1,
                                               0.5, 0.5,
                                               GridBagConstraints.NORTHWEST,
                                               GridBagConstraints.HORIZONTAL,
                                               new Insets(0, 0, 0, (counter + 1) % 2 != 0 ? 30 : 0),
                                               0, 0));
        // Click
        button.addActionListener(new ActionListener(){
          @Override
          public void actionPerformed(ActionEvent e) {
            TransitionManager.showGanttEdit();
          }      
        });
    }

    /////////////////////////////////////////////////////////////////////////

    // Boutton personalise
    private class TaskButton extends JButton {

      /////////////////////////////////////////////////////////////////////////

        // taille
        private Dimension componentDimension = new Dimension(0, 0);
        // Image
        private BufferedImage image;
        // Zone cliquable
        private Rectangle clickable;
        // valeur des effets
        private float ghostValue = 0.0f;
        private float newFraction = 0.0f;
        // variation entre  les valeurs de l'effet et les valeurs courantes
        private int distance_r;
        private int distance_g;
        private int distance_b;
        // Valeur du mode RGB
        private int color_r;
        private int color_g;
        private int color_b;
        // Attributs
        private final String name;
        private final String description;
        private final String imageName;
        
        /////////////////////////////////////////////////////////////////////////

        // Boutton perso
        private TaskButton(String name, String description, String imageName) {
            this.name = name;
            this.description = description;
            this.imageName = imageName;
            // Ne prend pas le focus quand on click
            setFocusable(false);
            // Pas de bord
            setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
            // On s'occupe de l'arriere plan
            setOpaque(false);
            // Les contours sont transparents
            setContentAreaFilled(false);
            setFocusPainted(false);
            setBorderPainted(false);
            // Ajustement de l'image
            new ImageFetcher().execute();
            // On initialise le mode RGB
            color_r = categoryColor.getRed();
            color_g = categoryColor.getGreen();
            color_b = categoryColor.getBlue();
            // Ajout des listeners
            addMouseListener(new MouseClickHandler());
            // Effet d'eclat
            addMouseMotionListener(new GhostHandler());
            // Surlignage en blanc
            HiglightHandler higlightHandler = new HiglightHandler();
            addMouseListener(higlightHandler);
            addMouseMotionListener(higlightHandler);
        }
      
        /////////////////////////////////////////////////////////////////////////

        @Override
        protected void fireActionPerformed(ActionEvent e) {}
        
        // Classe de redimensionnement de l'image
        private class ImageFetcher extends SwingWorker {
            
            @Override
            // Recuperation de l'image
            protected Object doInBackground() throws Exception {
                getImage();
                return image;
            }
            
            @Override
            // Redimensionnementy et ajout de l'effet
            protected void done() {
                componentDimension = computeDimension();
                revalidate();
            }
        }

        private void getImage() {
            // Recuperation de l'image dans les resources
            try {
                this.image = ImageIO.read(getClass().getResource(imageName));
            } catch (IOException e) {
                e.printStackTrace();
            }
            // Création d'un mask pour la reflexion
            BufferedImage mask = Reflection.createGradientMask(image.getWidth(),
                                                               image.getHeight());
            // Application du mask a l'image
            this.image = Reflection.createReflectedPicture(image, mask);
        }

        private Dimension computeDimension() {
          
            Insets insets = getInsets();
            // recuperation du type de taille utilise pour le titre
            FontMetrics metrics = getFontMetrics(categoryFont);
            // Recupération de la taille maximum d'un caractere
            Rectangle2D bounds = metrics.getMaxCharBounds(getGraphics());
            // On callcul la hauteur en ajoutant les iinterlignes
            int height = (int) bounds.getHeight() + metrics.getLeading();
            // La longueur du titre
            int nameWidth = SwingUtilities.computeStringWidth(metrics, name);
            
            // recuperation du type de taille utilise pour le sous titre
            metrics = getFontMetrics(categorySmallFont);
            bounds = metrics.getMaxCharBounds(getGraphics());
            height += bounds.getHeight();
            int descWidth = SwingUtilities.computeStringWidth(metrics,
                                                              description == null ? "" : description);
            // calcul de la hauteur max
            int width = Math.max(nameWidth, descWidth);
            width += image.getWidth() + 10;

            // Creation de la zone clickable
            clickable = new Rectangle(insets.left, insets.top /*+ 4*/,
                                      width /*+ insets.left + insets.right*/,
                                      height /*+ insets.top + insets.bottom*/);
            // Ajout d'un lien clickable
            HyperlinkHandler.add(this, clickable);
            // Calcul de la hauteur utile
            height = Math.max(height, image.getHeight());
            height += 4;
            // Retour de la hauteur utile
            return new Dimension(width + insets.left + insets.right,
                                 height + insets.top + insets.bottom);
        }

        @Override
        public Dimension getMinimumSize() {return getPreferredSize();}
        @Override
        public Dimension getPreferredSize() {return componentDimension;}

        @Override
        protected void paintComponent(Graphics g) {
            if (!isVisible())
                return;
            // recuperation du graphics du composants
            Graphics2D g2 = (Graphics2D) g;
            // initialisation graphique
            setupGraphics(g2);
            // dessin du text
            float y = paintText(g2);
            // redessin du text
            paintImage(g2, y);
        }
        
        // dessine l'image du boutton
        private void paintImage(Graphics2D g2, float y) {
            // Position courante
            Insets insets = getInsets();
            // Si on est en mode survole, on dessine l'effet
            if (ghostValue > 0.0f) {
                // Taille courante, depend de ghost value
                int newWidth = (int) (image.getWidth() * (1.0 + ghostValue / 2.0));
                int newHeight = (int) (image.getHeight() * (1.0 + ghostValue / 2.0));

                Composite composite = g2.getComposite();
                g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
                                                           0.7f * (1.0f - ghostValue)));
                // Dessin de l'image
                g2.drawImage(image,
                             insets.left + (image.getWidth() - newWidth) / 2,
                             4 + (int) (y - newHeight / (5.0 / 3.0)) -
                             (image.getWidth() - newWidth) / 2,
                             newWidth, newHeight, null);
                g2.setComposite(composite);
            }
            // On dessine l'image
            g2.drawImage(image, null,
                         insets.left,
                         4 + (int) (y - image.getHeight() / (5.0 / 3.0)));
        }
        
        // Ecriture du text
        private float paintText(Graphics2D g2) {
            // Affectation de la police utilisee
            g2.setFont(categoryFont);
            // Position courante
            Insets insets = getInsets();
            // Cration de la mise en page du text
            FontRenderContext context = g2.getFontRenderContext();
            TextLayout layout = new TextLayout(name,
                                               categoryFont, context);
            // Calcul de la taille necessaire  a l'image
            float x = image.getWidth() + 10.0f;
            x += insets.left;
            float y = 4.0f + layout.getAscent() - layout.getDescent();
            y += insets.top;
            // Effet de dégradé sur le text
            g2.setColor(shadowColor);
            Composite composite = g2.getComposite();
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
                                                       shadowOpacity));
            layout.draw(g2, shadowOffsetX + x, shadowOffsetY + y);
            g2.setComposite(composite);

            g2.setColor(new Color(color_r, color_g, color_b));
            layout.draw(g2, x, y);
            y += layout.getDescent();

            layout = new TextLayout(description == null ? " " : description,
                                    categorySmallFont, context);
            y += layout.getAscent();
            composite = g2.getComposite();
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
                                                       categorySmallOpacity));
            layout.draw(g2, x, y);
            g2.setComposite(composite);

            return y;
        }

        // Configuration graphique
        private void setupGraphics(Graphics2D g2) {
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        }

        // Gestion de l'eclat au survol
        private final class GhostHandler extends MouseMotionAdapter {
            private Animator timer;
            // Survol de la souris d'un boutton
            @Override
            public void mouseMoved(MouseEvent e) {
                // Si on a pas clique dans la zone, on quitte
                if (!clickable.contains(e.getPoint()) || mouseEnter)
                    return;
                // Si l'animation est deja lance, on quitte
                if (timer != null && timer.isRunning())
                    return;
                // Calcul de la variation de couleur entre l'eclat et le mode normal
                distance_r = categoryHighlightColor.getRed() -
                    categoryColor.getRed();
                distance_g = categoryHighlightColor.getGreen() -
                    categoryColor.getGreen();
                distance_b = categoryHighlightColor.getBlue() -
                    categoryColor.getBlue();
                // lancement de l'animation
                timer = new Animator(450, new AnimateGhost());
                timer.start();
            }
        }
        // Click
        private final class MouseClickHandler extends MouseAdapter {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (clickable.contains(e.getPoint())) 
                    for (ActionListener l : getActionListeners()) 
                        l.actionPerformed(new ActionEvent(TaskButton.this, 462, ""));                                  
            }
        }

        private final class AnimateGhost implements TimingTarget {
            @Override
            public void timingEvent(float fraction) {
                ghostValue = fraction;
                repaint();
            }

            @Override
            public void begin() {
                ghostValue = 0.0f;
            }

            @Override
            public void end() {
                ghostValue = 0.0f;
                repaint();
            }
            @Override
            public void repeat() {            	
            }
        }

        /////////////////////////////////////////////////////////////////////////

        private final class HiglightHandler extends MouseMotionAdapter implements MouseListener {
            private Animator timer;
            
            @Override
            public void mouseMoved(MouseEvent e) {
                if (clickable.contains(e.getPoint())) {
                    if (!mouseEnter) {
                        mouseEnter = true;
                        if (timer != null && timer.isRunning()) 
                            timer.stop();
                        timer = new Animator(450, new AnimateHighlight(true));
                        timer.start();
                    }
                } else if (mouseEnter) {
                    mouseEnter = false;
                    if (timer != null && timer.isRunning()) 
                        timer.stop();
                    timer = new Animator(450, new AnimateHighlight(false));
                    timer.start();
                }
            }

            @Override
            public void mouseClicked(MouseEvent e) {}
            @Override
            public void mousePressed(MouseEvent e) {}
            public void mouseReleased(MouseEvent e) {}
            public void mouseEntered(MouseEvent e) {
                mouseEnter = false;
            }
            public void mouseExited(MouseEvent e) {}
            
            /////////////////////////////////////////////////////////////////////////

        }

        /////////////////////////////////////////////////////////////////////////

        private final class AnimateHighlight implements TimingTarget {
          
          /////////////////////////////////////////////////////////////////////////

            private boolean forward;
            private float oldValue;

            /////////////////////////////////////////////////////////////////////////

            AnimateHighlight(boolean forward) {
                this.forward = forward;
                oldValue = newFraction;
            }

            /////////////////////////////////////////////////////////////////////////

            public void repeat() {}
            
            public void timingEvent(float fraction) {
                newFraction = oldValue + fraction * (forward ? 1.0f : -1.0f);

                if (newFraction > 1.0f) 
                    newFraction = 1.0f;
                else if (newFraction < 0.0f)
                    newFraction = 0.0f;

                color_r = (int) (categoryColor.getRed() + distance_r * newFraction);
                color_g = (int) (categoryColor.getGreen() + distance_g * newFraction);
                color_b = (int) (categoryColor.getBlue() + distance_b * newFraction);

                repaint();
            }

            public void begin() {}
            public void end() {}
        }
        
        /////////////////////////////////////////////////////////////////////////

    }

    /////////////////////////////////////////////////////////////////////////


    /////////////////////////////////////////////////////////////////////////

    public static class UserListModel extends AbstractListModel{
      Workspace workspace;
      public UserListModel(Workspace workspace){
        this.workspace = workspace;
      }
      
          @Override
          public int getSize() { return workspace.getCurrentProject().getWorkersList().size(); }
          @Override
          public Object getElementAt(int i) { return workspace.getCurrentProject().getWorkersList().get(i).getFirstName() + " "+
                  workspace.getCurrentProject().getWorkersList().get(i).getLastName(); }
          public Worker getWorker(int i) { return workspace.getCurrentProject().getWorkersList().get(i);}
          
          public void deleteWorker ( Worker worker){
            workspace.getCurrentProject().getWorkersList().remove(worker);
          }
      
    }
    
     public static class ManagerListModel extends AbstractListModel{
      Workspace workspace;
      public ManagerListModel(Workspace workspace){
        this.workspace = workspace;
      }
      
          @Override
          public int getSize() { return workspace.getCurrentProject().getManagers().size(); }
          @Override
          public Object getElementAt(int i) { return workspace.getCurrentProject().getManagers().get(i).getFirstName() + " "+
                  workspace.getCurrentProject().getManagers().get(i).getLastName(); }
          public Worker getWorker(int i) { return workspace.getCurrentProject().getManagers().get(i);}
          
          public void deleteWorker ( Worker worker){
            workspace.getCurrentProject().getManagers().remove(worker);
          }      
    }
        
 
    public static class UserTaskListModel extends AbstractListModel{
      Workspace workspace;
      public UserTaskListModel(Workspace workspace){
        this.workspace = workspace;
      }
      
          @Override
          public int getSize() { return workspace.getCurrentTask().getWorkersList().size(); }
          @Override
          public Object getElementAt(int i) { return workspace.getCurrentTask().getWorkersList().get(i).getFirstName() + " "+
                  workspace.getCurrentTask().getWorkersList().get(i).getLastName(); }
          public Worker getWorker(int i) { return workspace.getCurrentTask().getWorkersList().get(i);}
          
          public void deleteWorker ( Worker worker){
            workspace.getCurrentTask().getWorkersList().remove(worker);
          } 
    }       
        
    public class MonFiltre extends FileFilter {

    String []lesSuffixes;
    String  laDescription;

   public MonFiltre(String []lesSuffixes, String laDescription){
        this.lesSuffixes = lesSuffixes;
        this.laDescription = laDescription;
   }

   boolean appartient( String suffixe ){
      for( int i = 0; i<lesSuffixes.length; ++i){
          if(suffixe.equals(lesSuffixes[i])) return true;
      }
      return false;
   }

   public boolean accept(File f) {
     if (f.isDirectory()) {
         return true;
     }
     String suffixe = null;
     String s = f.getName();
     int i = s.lastIndexOf('.');
    if (i > 0 &&  i < s.length() - 1) {
         suffixe = s.substring(i+1).toLowerCase();
     }
     return suffixe != null && appartient(suffixe);
   }

   // la description du filtre
   public String getDescription() {
       return laDescription;
   }
  }

  public static class ResizingImage {

  static BufferedImage imgNew = null;


  public static BufferedImage resize(int newWidth, int newHeight, String imgPath) {

  try {
  File imgFile = new File(imgPath);
  BufferedImage imgOld = ImageIO.read(imgFile);
  imgNew = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_RGB);

  /// Resizing of the old image ////////////////////////
  Graphics2D g = (Graphics2D) imgNew.getGraphics();
  g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
  g.drawImage(imgOld, 0, 0, newWidth, newHeight, null);
  g.dispose();
  /////////////////////////////////////////////////////

  } catch (IOException e) {
  e.printStackTrace();
  }

  return imgNew;
  }



  public static BufferedImage resize(int newWidth, int newHeight, String imgPath, String strg) {

  imgNew = resize(newWidth, newHeight, imgPath);

  try {
  ImageIO.write(imgNew, "jpeg", new File(strg));
  } catch (IOException e) {
  e.printStackTrace();
  }

  return imgNew;
  }

  } 


}

/////////////////////////////////////////////////////////////////////////
